/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.wx.statweb.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class PicCopy {

    public static void copyFile(File srcFile, File targetFile) {
        try {
            InputStream pic = new FileInputStream(srcFile);
            OutputStream os = new FileOutputStream(targetFile);
            int byteCount = 0;
            byte[] bytes = new byte[1024];
            while ((byteCount = pic.read(bytes)) != -1) {
                os.write(bytes, 0, byteCount);
            }
            os.flush();
            os.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("文件复制成功");

    }
    
        public static String readProperties(String key) {
        String value = "";
        try {
            Properties properties = new Properties();
            InputStream inputStream = PicCopy.class.getClassLoader().getResourceAsStream("configuration.properties");
            properties.load(inputStream);
            value = properties.getProperty(key);
            inputStream.close();
            properties.clear();
        } catch (IOException ex) {
            Logger.getLogger(PicCopy.class.getName()).log(Level.SEVERE, null, ex);
        }
        return value;
    }

}
